/*-------------------------------------------------------------------------
 *
 * parse_oper.h
 *		处理解析器的操作符相关事务
 *
 *
 * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 * src/include/parser/parse_oper.h
 *
 *-------------------------------------------------------------------------
 */
#ifndef PARSE_OPER_H
#define PARSE_OPER_H

#include "access/htup.h"
#include "nodes/parsenodes.h"
#include "parser/parse_node.h"


typedef HeapTuple Operator;

/* 按名称和确切输入类型查找运算符的例程 */
extern Oid	LookupOperName(ParseState *pstate, List *opername,
						   Oid oprleft, Oid oprright,
						   bool noError, int location);
extern Oid	LookupOperWithArgs(ObjectWithArgs *oper, bool noError);

/* 按名称和给定输入类型查找匹配运算符的例程 */
/* 注意：选择的运算符可能需要输入类型的强制转换！ */
extern Operator oper(ParseState *pstate, List *op, Oid arg1, Oid arg2,
					 bool noError, int location);
extern Operator left_oper(ParseState *pstate, List *op, Oid arg,
						  bool noError, int location);

/* 查找不需要强制转换的运算符的例程 --- 即，它们的 */
/* 输入类型要么完全如给出，要么是二进制兼容的 */
extern Operator compatible_oper(ParseState *pstate, List *op,
								Oid arg1, Oid arg2,
								bool noError, int location);

/* 目前不需要 compatible_left_oper/compatible_right_oper */

/* 用于识别 "<", "=", ">" 运算符的常规程序 */
extern void get_sort_group_operators(Oid argtype,
									 bool needLT, bool needEQ, bool needGT,
									 Oid *ltOpr, Oid *eqOpr, Oid *gtOpr,
									 bool *isHashable);

/* 上述常用调用的便利例程 */
extern Oid	compatible_oper_opid(List *op, Oid arg1, Oid arg2, bool noError);

/* 从运算符元组中提取运算符OID或基础函数OID */
extern Oid	oprid(Operator op);
extern Oid	oprfuncid(Operator op);

/* 为运算符调用构建表达式树 */
extern Expr *make_op(ParseState *pstate, List *opname,
					 Node *ltree, Node *rtree, Node *last_srf, int location);
extern Expr *make_scalar_array_op(ParseState *pstate, List *opname,
								  bool useOr,
								  Node *ltree, Node *rtree, int location);

#endif							/* PARSE_OPER_H */
